class Test {
    public static int add(int x, int y) {
        return x + y;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(add(a, b));

        double n = 20.0;
        double m = 30.5;
        //System.out.println(add(n, m));
    }
}

class Test2 {
    public static int addInt(int x, int y) {
        return x + y;
    }

    public static double addDouble(double x, double y) {
        return x + y;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int ret = addInt(a, b);
        System.out.println("ret = " + ret);

        double a2 = 10.5;
        double b2 = 20.5;
        double ret2 = addDouble(a2, b2);
        System.out.println("ret2 = " + ret2);
    }
}

class Test3 {
    public static int add(int x, int y) {
        return x + y;
    }

    public static double add(double x, double y) {
        return x + y;
    }

    public static double add(double x, double y, double z) {
        return x + y + z;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(add(a, b));

        double n = 10.5;
        double m = 55.3;
        System.out.println(add(n, m));

        double i = 11.1;
        double j = 22.2;
        double k = 33.3;
        System.out.println(add(i, j, k));
    }
}

//class Test4 {
//    public static int add(int x, int y) {
//        return x + y;
//    }
//
//    public static double add(int x, int y) {
//        return x + y;
//    }
//
//    public static void main(String[] args) {
//        int a = 10;
//        int b = 20;
//        int ret = add(a, b);
//        System.out.println("ret = " + ret);
//    }
//
//}

class Test5 {

    public static int factorial(int n) {
        if (n == 1) {
            return 1;
        }
        return n * factorial(n - 1);
    }

    public static void main(String[] args) {
        int n = 5;
        int ret = factorial(n);
        System.out.println(ret);
    }
}

class Test6 {
    public static int factor(int n) {
        System.out.println("函数开始，n = " + n);
        if (n == 1) {
            System.out.println("函数结束，n = 1，ret = 1");
            return 1;
        }
        int ret = n * factor(n - 1);
        System.out.println("函数结束，n = " + n + " ret = " + ret);
        return ret;
    }

    public static void main(String[] args) {
        int n = 5;
        int ret = factor(n);
        System.out.println(" ret = " + ret);
    }
}

class Test7 {
    public static void print(int num) {
        if (num > 9) {
            print(num / 10);
        }
        System.out.println(num % 10);
    }

    public static void main(String[] args) {
        int n = 1234;
        print(n);
    }
}

class Test8 {
    public static int sum(int num) {
        if (num == 1) {
            return 1;
        }
        return num + sum(num - 1);
    }

    public static void main(String[] args) {
        int i = 10;
        System.out.println(sum(10));

    }
}

class Test9 {
    public static int sum(int num) {
        if (num < 10) {
            return num;
        }
        return num % 10 + sum(num / 10);
    }

    public static void main(String[] args) {
        int n = 1729;
        System.out.println(sum(n)); // 输出 19
    }
}